<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
    <xsl:param name="DOTNET2"/>


	<xsl:template match="Class">
		<xsl:variable name="Name" select="Name"/>
        <xsl:variable name="HeaderInfo" select="HeaderInfo/ProjectName"/>


using System;
using System.Configuration;

using Castle.ActiveRecord;
using Castle.ActiveRecord.Framework;

using System.Collections.Generic;

using NUnit.Framework;

namespace <xsl:value-of select="HeaderInfo/ProjectName"/>.ActiveRecord.Tests 
{

	<xsl:if test="IsComposite='false' and IsNested='false'">
	[TestFixture]
	public class <xsl:value-of select="Name"/>DatabaseTest : NUnitBase
	{
		
	
		[SetUp]
		public void SetUp ()
		{
			base.SetUp();
		}
	
	
		[TearDown]
		public void TearDown ()
		{
			base.TearDown();
		}
		
		[TestFixtureSetUp]
		public void TestFixtureSetUp ()
		{
			// need to get the executing assembly, find all the types that
			// derive from DataObject and use those to populate this list
			
			List&lt;Type&gt; types = new List&lt;Type&gt;();
			
			foreach ( Type type in System.Reflection.Assembly.GetAssembly ( this.GetType () ).GetTypes () )
			{
				if ( type.BaseType == typeof ( <xsl:value-of select="HeaderInfo/ProjectName"/>.ActiveRecord.DataObject ) ) types.Add ( type );
			}
			
			
			base.TestFixtureSetUp ( types.ToArray() );
			
		}
		
		
		[Test]
		public void HasRecords ()
		{
			int records = <xsl:value-of select="HeaderInfo/ProjectName"/>.ActiveRecord.<xsl:value-of select="Name"/>.FindAll ().Length;
				
			Console.WriteLine ( "<xsl:value-of select="Name"/> Records : " + records );

			Assert.IsTrue ( records > 0 );
		}
		
		
		
	}
	</xsl:if>


	[TestFixture]
	public class <xsl:value-of select="Name"/>PropertyTest : NUnitBase
	{
	

	
		<xsl:for-each select="ClassAttribs/ClassAttributes[CType='single' and KnownClass='false' and IsEnum='false']">
		[Test]
		public void <xsl:value-of select="PropertyName"/> ()
		{
			<xsl:value-of select="//HeaderInfo/ProjectName"/>.ActiveRecord.<xsl:value-of select="$Name"/> obj
				= new <xsl:value-of select="//HeaderInfo/ProjectName"/>.ActiveRecord.<xsl:value-of select="$Name"/> ();

			obj.<xsl:value-of select="PropertyName"/> = NUnitBase.Test_<xsl:value-of select="Type"/>;
			Assert.IsTrue ( obj.<xsl:value-of select="PropertyName"/>.Equals ( NUnitBase.Test_<xsl:value-of select="Type"/> ) );
		}
		
		</xsl:for-each>	
		
		
		[Test]
		public void AllPropertiesAscending ()
		{
		
			<xsl:value-of select="//HeaderInfo/ProjectName"/>.ActiveRecord.<xsl:value-of select="Name"/> obj
					= new <xsl:value-of select="//HeaderInfo/ProjectName"/>.ActiveRecord.<xsl:value-of select="Name"/> ();
				
			
			<xsl:for-each select="ClassAttribs/ClassAttributes[CType='single' and KnownClass='false' and IsEnum='false']"><xsl:sort select="PropertyName" order="ascending"/>
			obj.<xsl:value-of select="PropertyName"/> = NUnitBase.Test_<xsl:value-of select="Type"/>;</xsl:for-each>
			
			<xsl:for-each select="ClassAttribs/ClassAttributes[CType='single' and KnownClass='false' and IsEnum='false']"><xsl:sort select="PropertyName" order="ascending"/>
			Assert.IsTrue ( obj.<xsl:value-of select="PropertyName"/>.Equals ( NUnitBase.Test_<xsl:value-of select="Type"/> ) );</xsl:for-each>		
			
		}
		
		
		[Test]
		public void AllPropertiesDescending ()
		{
		
			<xsl:value-of select="//HeaderInfo/ProjectName"/>.ActiveRecord.<xsl:value-of select="Name"/> obj
					= new <xsl:value-of select="//HeaderInfo/ProjectName"/>.ActiveRecord.<xsl:value-of select="Name"/> ();
				
			
			<xsl:for-each select="ClassAttribs/ClassAttributes[CType='single' and KnownClass='false' and IsEnum='false']"><xsl:sort select="PropertyName" order="descending"/>
			obj.<xsl:value-of select="PropertyName"/> = NUnitBase.Test_<xsl:value-of select="Type"/>;</xsl:for-each>


			<xsl:for-each select="ClassAttribs/ClassAttributes[CType='single' and KnownClass='false' and IsEnum='false']"><xsl:sort select="PropertyName" order="descending"/>
			Assert.IsTrue ( obj.<xsl:value-of select="PropertyName"/>.Equals ( NUnitBase.Test_<xsl:value-of select="Type"/> ) );</xsl:for-each>		
		
		}
	
	}




}
		

	</xsl:template>
	
	
	
</xsl:stylesheet>